package com.mstar.qs.common.thread;

public class ThreadUtil {
	public static StackTraceElement obtainRuntime(int index) {
		if(index<=0) throw new IllegalArgumentException("index:"+index);
		StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
		if (stackTrace == null || stackTrace.length < index)
			return null;
		StackTraceElement e = stackTrace[index-1];
		return e;
	}
	
	public static StackTraceElement obtainInvoker() {
		return obtainRuntime(4);
	}
	
	public static String obtainInvokerModifierMethod() {
		StackTraceElement e =obtainRuntime(4);
		return e.getClassName()+":"+e.getMethodName()+":"+e.getLineNumber();
	}
}
